# -*- coding:utf-8 -*-
#  <pre>
# 	@Description 该类文件为公共配置信息
#  </pre>
#  @copyright www.timotai.net
#  @author 这家伙真懒
#  @date 2016-1-10

import time


# 根据主机的语言环境该monitor_data要更改   JVM 运行时   对象请求代理  都要换成中文
monitor_data=['JVM 运行时','对象请求代理','WebContainer']



# 多台主机以列表形势配置
# test_yyapp=['test_yyapp_node1','test_yyapp_node2','test_yyapp_node3','test_yyapp_node4','test_yyapp_node5','test_yyapp_node6','test_yyapp_node7','test_yyapp_node8','test_yyapp_node9','test_yyapp_node10']
test_yyapp=['test_yyapp_node1']

# 是否打开日志文件
is_debug = False 

# 抓包的头文件
user_agent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.104 Safari/537.36'

headers = {'User-Agent':user_agent}

# 正则表达式的配置
CONTENT_RE = r'<Stat name="%s">.*?</Stat>'
COUNT_RE = r'.*?count="(.*?)".*?name="(.*?)"'
VALUE_RE = r'.*?name="(.*?)".*?value="(.*?)"'
HTTP_RE = r'http://(.*?):.*?=(.*)'

# 脚本路径根据实际情况修改
FILEPATH='/home/was/tools/python/'

# 数据库参数配置
SHOW_SQL = True
TABLE_NAME = 'was_monitor'
DB_FILE_PATH = '/home/was/tools/python/was_monitor.db'
TABLE_NAME=['jvmdata','threaddata']
CREATE_JVM_SQL = '''CREATE TABLE [{0}{1}] (
              [id] integer NOT NULL,
              [ProcessCpuUsage] integer DEFAULT (0),
              [UpTime] integer DEFAULT (0),
              [UsedMemory] integer DEFAULT (0),
              [HeapSize] integer DEFAULT (0),
              [FreeMemory] integer DEFAULT (0),
              [currentDate] varchar DEFAULT (''),
              [serverName] varchar DEFAULT (''),
              PRIMARY KEY ([id]));
            '''

CREATE_THREAD_SQL = '''CREATE TABLE [{0}{1}] (
              [id] integer NOT NULL,
              [ActiveCount] integer DEFAULT (0),
              [ClearedThreadHangCount] integer DEFAULT (0),
              [ConcurrentHungThreadCount] integer DEFAULT (0),
              [CreateCount] integer DEFAULT (0),
              [DeclaredThreadHungCount] integer DEFAULT (0),
              [DestroyCount] integer DEFAULT (0),
              [PercentMaxed] integer DEFAULT (0),
              [PercentUsed] integer DEFAULT (0),
              [PoolSize] integer DEFAULT (0),
              [currentDate] varchar DEFAULT (''),
	      [serverName] varchar DEFAULT (''),
              [type] integer DEFAULT (0),
              PRIMARY KEY ([id]));
            '''
CREATE_INDEX='CREATE INDEX [{0}{1}] ON [{2}{3}] ([serverName] ASC);'
# INSERT_SQL = 'insert into datainfo20151226 (ActiveCount,ActiveCount,ClearedThreadHangCount,ConcurrentHungThreadCount,CreateCount,DeclaredThreadHungCount,DestroyCount,PercentMaxed,PercentUsed,PoolSize,ProcessCpuUsage,UpTime,UsedMemory,HeapSize,FreeMemory,type ) values (0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)'

INSERT_SQL = 'insert into {0}{1} '

VALUES = ' values '

DBQUEUE = time.strftime('%Y%m%d', time.localtime())

IS_TABLE_EXIST = 'SELECT tbl_name FROM sqlite_master WHERE type="table" and tbl_name="{0}{1}"'


# 主机上每个SERVER的URL，根据该URL获取性能数据
test_yyapp_node1=('http://127.0.0.1:10400/wasPerfTool/servlet/perfservlet?server=test-server-bda1-node1-srv',
'http://127.0.0.1:11100/wasPerfTool/servlet/perfservlet?server=test-server-bdb1-node1-srv',
'http://127.0.0.1:10200/wasPerfTool/servlet/perfservlet?server=test-server-bdc1-node1-srv',
'http://127.0.0.1:10100/wasPerfTool/servlet/perfservlet?server=test-server-bdd1-node1-srv',
'http://127.0.0.1:10500/wasPerfTool/servlet/perfservlet?server=test-server-bde2-node1-srv',
'http://127.0.0.1:10800/wasPerfTool/servlet/perfservlet?server=test-server-bdf1-node1-srv')


